<%@ page pageEncoding="utf-8"   isELIgnored="false"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="path" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>生成订单 - 当当网</title>
		<link href="${pageContext.request.contextPath}/front/css/login.css" rel="stylesheet" type="text/css" />
		<link href="${pageContext.request.contextPath}/front/css/page_bottom.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="${pageContext.request.contextPath}/front/js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript">
	
			function selectOne(addressId){
			
				location.href="${pageContext.request.contextPath}/frontassress/showOneAddress?addressIdl="+addressId
			}
			
			$(function(){
			var receive=false;
				var Address=false;
				var Code=false;
				var mobile=false;
			//收件人验证
				$("#receiveName").blur(function(){
					//获取email
					var nam=$("#receiveName").val();	
					//判断是否为空
					if(nam==""){
						$("#emailMsg").html("请填写有效的收件人姓名");
					}else{
						//判断格式是否正确
						//var s=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
						if(nam.length>=2){
							$("#emailMsg").html("验证成功").css("color","green");
							receive=true;
						}else{
							$("#emailMsg").html("请填写有效的收件人姓名");
						}
					}
				});
				
				
				
			
			//});
			
			//收件人详细地址验证
			//$(function(){
			//收件人验证
				$("#fullAddress").blur(function(){
					//获取email
					var adsress=$("#fullAddress").val();	
					//判断是否为空
					if(adsress==""){
						$("#nameMsg").html("请填写有效的收件人的详细地址");
					}else{
						//判断格式是否正确
						//var s=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
						if(adsress.length>=12){
							$("#nameMsg").html("验证成功").css("color","green");
							Address=true;
						}else{
							$("#nameMsg").html("请填写有效的收件人的详细地址");
						}
					}
				});
			
			//});
			
			//邮政编码验证
			//$(function(){
			//收件人验证
				$("#postalCode").blur(function(){
					//获取email
					var adsress=$("#postalCode").val();	
					//判断是否为空
					if(adsress==""){
						$("#postalCodeMsg").html("请填写有效的收件人的邮政编码");
					}else{
						//判断格式是否正确
						//var s=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
						if(adsress.length==6){
							$("#postalCodeMsg").html("验证成功").css("color","green");
							Code=true;
						}else{
							$("#postalCodeMsg").html("请填写有效的收件人的邮政编码");
						}
					}
				});
			
			//});
			
			//手机验证
			//$(function(){
			//收件人验证
				$("#mobile").blur(function(){
					//获取email
					var adsress=$("#mobile").val();	
					//判断是否为空
					if(adsress==""){
						$("#mobileMsg").html("请填写有效的收件人的手机");
					}else{
						//判断格式是否正确
						//var s=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
						if(adsress.length==11){
							$("#mobileMsg").html("验证成功").css("color","green");
							emails=true;
						}else{
							$("#mobileMsg").html("请填写有效的收件人的手机");
						}
					}
				});
				
				$("form").submit(function(){
					
					
					//将所有的表单验证验证一遍，
					$("input").trigger('blur');
					//alert(email && isOK2 && isOK3 && isOK4 && isOK5);
					/* alert("emails"+emails);
					alert("isOK2"+isOK2);
					alert("isOK3"+isOK3);
					alert("isOK4"+isOK4);
					alert("isOK5"+isOK5);  */
					//判断是否验证通过
					if(receive && Address && Code && isOK4 && mobile){
						
						//提交表单
						$("form").submit();
					}else{
						return false;
					}
				});
			
			});
			
			
		</script>

	</head>
	<body>
		<%@include file="/front/common/head1.jsp"%>
		<div class="login_step">
			生成订单骤: 1.确认订单 >
			<span class="red_bold"> 2.填写送货地址</span> > 3.订单成功
		</div>
		<div class="fill_message">
			<p>
				选择地址:
				<select id="address" onchange="selectOne(this.value)">
					<option value="">填写新地址</option>
					<c:forEach items="${addressList}" var="list">
					 <c:if test="${list.id == fra1.id}">${fra1.detail}
					 <option value="${list.id}"  selected>${list.detail}</option><%-- "  "${list.detail} --%>
					</c:if>
					<c:if test="${list.id != fra1.id}">${fra1.detail}
					 <option value="${list.id}"  >${list.detail}</option><%-- "  "${list.detail} --%>
					</c:if>
					</c:forEach>
				</select>
			</p>
			<form name="ctl00" method="post" action="${path}/frontassress/addAddress?fra.id=${fra1.id}" id="f">
				<input type="hidden" name="id" id="addressId" />

				<table class="tab_login">
					<tr>
						<td valign="top" class="w1">
							收件人姓名：
						</td>
						<td>
							<input type="text" class="text_input" name="fra.name" id="receiveName" value="${fra1.name}"/>
							<div class="text_left" id="nameValidMsg">
								<p>
								<span id="emailMsg" style="color:red"></span>
									
								</p>
							</div>
						</td>
					</tr>
					<tr>
						<td valign="top" class="w1">
							收件人详细地址：
						</td>
						<td>
							<input type="text" name="fra.detail" class="text_input" id="fullAddress"  value="${fra1.detail}"/>
							<div class="text_left" id="addressValidMsg">
								<p>
									
									<span id="nameMsg" style="color:red"></span>
								</p>
							</div>
						</td>
					</tr>
					<tr>
						<td valign="top" class="w1">
							邮政编码
						</td>
						<td>
							<input type="text" class="text_input" name="fra.zip_code" id="postalCode"  maxlength="6" value="${fra1.zip_code}"/>
							<div class="text_left" id="codeValidMsg">
								<p>
								<span id="postalCodeMsg" style="color:red"></span>
									
								</p>
							</div>
						</td>
					</tr>
				
					<tr>
						<td valign="top" class="w1">
							手机
						</td>
						<td>
							<input type="text" class="text_input" name="fra.mobile" id="mobile" maxlength="11" value="${fra1.mobile}"/>
							<div class="text_left" id="mobileValidMsg">
								<p>
									<span id="mobileMsg" style="color:red"></span>
								</p>
							</div>
						</td>
					</tr>
				</table>

				<div class="login_in">
					<a href="order_info.jsp">
						<input id="btnClientRegister" class="button_1" name="submit" type="submit" value="取消" />
					</a>			
				<input id="btnClientRegister" class="button_1" name="submit" type="submit" value="下一步" />
				</div>
			</form>
		</div>
		<%@include file="../common/foot1.jsp"%>
	</body>
</html>

